using DeZhen.CollaborationPlatform.Model.Common;
using SqlSugar;

namespace DeZhen.CollaborationPlatform.Model.Entities
{
    /// <summary>
    /// 接口调用日志表
    /// </summary>
    [SugarTable(TableName = "api_call_log", TableDescription = "接口调用日志表")]
    public class ApiCallLogs : BaseEntity
    {
        /// <summary>
        /// 关联的接口ID,关联api_management表id字段
        /// </summary>
        [SugarColumn(ColumnName = "api_id", ColumnDescription = "关联的接口ID,关联api_management表id字段")]
        public long? ApiId { get; set; }

        /// <summary>
        /// 接口URL
        /// </summary>
        [SugarColumn(ColumnName = "api_url", ColumnDescription = "接口URL")]
        public string? ApiUrl { get; set; }

        /// <summary>
        /// 请求方法(GET/POST/PUT/DELETE等)
        /// </summary>
        [SugarColumn(ColumnName = "api_method", ColumnDescription = "请求方法(GET/POST/PUT/DELETE等)")]
        public string? ApiMethod { get; set; }

        /// <summary>
        /// 请求唯一标识
        /// </summary>
        [SugarColumn(ColumnName = "request_id", ColumnDescription = "请求唯一标识")]
        public string? RequestId { get; set; }

        /// <summary>
        /// 客户端IP
        /// </summary>
        [SugarColumn(ColumnName = "client_ip", ColumnDescription = "客户端IP")]
        public string? ClientIp { get; set; }

        /// <summary>
        /// 用户代理
        /// </summary>
        [SugarColumn(ColumnName = "user_agent", ColumnDescription = "用户代理")]
        public string? UserAgent { get; set; }

        /// <summary>
        /// 用户ID(未登录为null)
        /// </summary>
        [SugarColumn(ColumnName = "user_id", ColumnDescription = "用户ID(未登录为null)")]
        public string? UserId { get; set; }

        /// <summary>
        /// 请求参数(JSON格式)
        /// </summary>
        [SugarColumn(ColumnName = "request_params", ColumnDescription = "请求参数(JSON格式)")]
        public string? RequestParams { get; set; }

        /// <summary>
        /// 请求体内容
        /// </summary>
        [SugarColumn(ColumnName = "request_body", ColumnDescription = "请求体内容")]
        public string? RequestBody { get; set; }

        /// <summary>
        /// 请求时间(精确到毫秒)
        /// </summary>
        [SugarColumn(ColumnName = "request_time", ColumnDescription = "请求时间(精确到毫秒)")]
        public DateTime? RequestTime { get; set; }

        /// <summary>
        /// 响应状态码
        /// </summary>
        [SugarColumn(ColumnName = "response_code", ColumnDescription = "响应状态码")]
        public int? ResponseCode { get; set; }

        /// <summary>
        /// 响应体内容
        /// </summary>
        [SugarColumn(ColumnName = "response_body", ColumnDescription = "响应体内容")]
        public string? ResponseBody { get; set; }

        /// <summary>
        /// 错误信息
        /// </summary>
        [SugarColumn(ColumnName = "error_message", ColumnDescription = "错误信息")]
        public string? ErrorMessage { get; set; }

        /// <summary>
        /// 执行耗时(毫秒)
        /// </summary>
        [SugarColumn(ColumnName = "execution_time", ColumnDescription = "执行耗时(毫秒)")]
        public int? ExecutionTime { get; set; }

        /// <summary>
        /// 服务器IP
        /// </summary>
        [SugarColumn(ColumnName = "server_ip", ColumnDescription = "服务器IP")]
        public string? ServerIp { get; set; }

        /// <summary>
        /// 状态：1-成功，0-失败
        /// </summary>
        [SugarColumn(ColumnName = "status", ColumnDescription = "状态：1-成功，0-失败")]
        public bool Status { get; set; } = true;
    }
}